package com.wf.LeetCode;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * @author mpk
 * @since 2024/6/20 21:12:03
 */
public class DestCity {

    public static void main(String[] args) {

        ArrayList<String> l1 = new ArrayList<>();
        l1.add("B");
        l1.add("C");
        ArrayList<String> l2 = new ArrayList<>();
        l2.add("D");
        l2.add("B");
        ArrayList<String> l3 = new ArrayList<>();
        l3.add("C");
        l3.add("A");

        ArrayList<List<String>> lists = new ArrayList<>();
        lists.add(l1);
        lists.add(l2);
        lists.add(l3);
        String s = destCity(lists);
        System.out.println(s);
    }

        public static String destCity(List<List<String>> paths) {

            ArrayList<String> s1 = new ArrayList<>();
            ArrayList<String> s2 = new ArrayList<>();

            for (List<String> path : paths) {

                for (int i = 0; i < path.size(); i++) {

                    s1.add(path.get(0));
                    s2.add(path.get(1));

                }

            }
            for (String s : s1) {
                    s2.remove(s);
            }

            return  s2.get(0);

        }

}
